using System;
using System.Globalization;
using System.Windows.Data;
using Autodesk.Revit.DB;

namespace CodRevit.Converters
{
    public class ParameterDisplayConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
#if RVT_24
            if (value is ForgeTypeId forgeTypeId)
            {
                if (forgeTypeId == SpecTypeId.String.Text)
                    return "文本";
                else if (forgeTypeId == SpecTypeId.Int.Integer)
                    return "整数";
                else if (forgeTypeId == SpecTypeId.Number)
                    return "数字";
                else if (forgeTypeId == SpecTypeId.Length)
                    return "长度";
                else if (forgeTypeId == SpecTypeId.Area)
                    return "面积";
                else if (forgeTypeId == SpecTypeId.Volume)
                    return "体积";
                else if (forgeTypeId == SpecTypeId.Angle)
                    return "角度";
                else if (forgeTypeId == SpecTypeId.Boolean.YesNo)
                    return "是/否";
                else if (forgeTypeId == SpecTypeId.Force)
                    return "力";
                else if (forgeTypeId == SpecTypeId.Mass)
                    return "质量";
                else if (forgeTypeId == SpecTypeId.Currency)
                    return "货币";
            }
#else
            if (value is ParameterType paramType)
            {
                switch (paramType)
                {
                    case ParameterType.Text:
                        return "文本";
                    case ParameterType.Integer:
                        return "整数";
                    case ParameterType.Number:
                        return "数字";
                    case ParameterType.Length:
                        return "长度";
                    case ParameterType.Area:
                        return "面积";
                    case ParameterType.Volume:
                        return "体积";
                    case ParameterType.Angle:
                        return "角度";
                    case ParameterType.YesNo:
                        return "是/否";
                    case ParameterType.Force:
                        return "力";
                    case ParameterType.Mass:
                        return "质量";
                    case ParameterType.Currency:
                        return "货币";
                }
            }
#endif
            else if (value is BuiltInParameterGroup paramGroup)
            {
                switch (paramGroup)
                {
                    case BuiltInParameterGroup.PG_GENERAL:
                        return "常规";
                    case BuiltInParameterGroup.PG_GEOMETRY:
                        return "几何";
                    case BuiltInParameterGroup.PG_CONSTRUCTION:
                        return "构造";
                    case BuiltInParameterGroup.PG_GRAPHICS:
                        return "图形";
                    case BuiltInParameterGroup.PG_DATA:
                        return "数据";
                    case BuiltInParameterGroup.PG_MATERIALS:
                        return "材质";
                    case BuiltInParameterGroup.PG_CONSTRAINTS:
                        return "约束";
                    case BuiltInParameterGroup.PG_IDENTITY_DATA:
                        return "标识数据";
                    case BuiltInParameterGroup.PG_PHASING:
                        return "阶段";
                    case BuiltInParameterGroup.PG_TEXT:
                        return "文字";
                    case BuiltInParameterGroup.PG_VISIBILITY:
                        return "可见性";
                    case BuiltInParameterGroup.PG_ADSK_MODEL_PROPERTIES:
                        return "Autodesk模型属性";
                    case BuiltInParameterGroup.PG_ANALYTICAL_MODEL:
                        return "分析模型";
                    case BuiltInParameterGroup.PG_STRUCTURAL:
                        return "结构";
                    case BuiltInParameterGroup.PG_IFC:
                        return "IFC参数";
                    case BuiltInParameterGroup.INVALID:
                        return "其他";
                }
            }

            return value?.ToString() ?? string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}